#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int T,n,m,L,V;
int d[100005];
int v[100005];
int a[100005];
int pos[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int minn=1,ans=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i],minn=min(minn,a[i]);
        for(int i=1;i<=m;i++) cin>>pos[i];
        sort(pos+1,pos+m+1);
        if(minn==0){
            for(int i=1;i<=n;i++) if(pos[m]>=d[i]&&v[i]>V) ans++;
            cout<<ans<<' '<<m-1<<'\n';
        }
        else if(minn>0){
            for(int i=1;i<=n;i++)
                if(pos[m]>=d[i]&&v[i]>V) ans++;
                else if(pos[m]>=d[i]&&2*a[i]*(pos[m]-d[i])+v[i]*v[i]>V*V) ans++;
            cout<<ans<<' '<<m-1<<'\n';
        }
    }
    return 0;
}
